/**
 * Created by Administrator on 2018/11/23.
 */
window.onload=function(){
        var account =  document.getElementById("account");
        var Phone =  document.getElementById("phone");
        var accountContext =  document.getElementById("accountContext");
        var PhoneContext =  document.getElementById("PhoneContext");
        //显示账号登录
        account.onclick = function(){
            PhoneContext.style.display="none";
            accountContext.style.display="block";
        }
        //显示手机号登陆登录的
        Phone.onclick = function(){
            PhoneContext.style.display="block";
            accountContext.style.display="none";
        }
        //表单的提交验证。
        var btn01 = document.getElementById("btn01");
        btn01.onclick=function(){
            //验证表单中的数据的合法性。
            //获得输入的用户名
            var account = form1.account.value;
            var pwd = form1.pwd.value;

            if(account==""){
                alert("请输入账号");
                form1.account.focus();
                return ;
            }
            if(pwd==""){
                alert("请输入密码");
                form1.pwd.focus();
                return ;
            }
            //把密码进行加密
            form1.pwd.value =  hex_md5(pwd);
            //提交表单
            form1.submit();
        }
        var btn02=document.getElementById("btn02");
        btn02.onclick=function () {

            var phone=form2.phone.value;
            if (!/^1[3|4|5|7|8][0-9]{9}$/.test(phone)){
                alert("手机号码不正规");
                return;
            }

            var url="/Bookstore/send?phone=" + phone;

            var req=new XMLHttpRequest();

            req.open("POST",url);
            req.send(null);
            req.onreadystatechange=function () {
                if(req.readyState==4){
                    if(req.status==200||req.status==304){
                        alert(req.response);
                    }
                }
            }

        }
    var btn03 = document.getElementById("btn03");
    btn03.onclick=function(){
        //验证表单中的数据的合法性。
        //获得输入的用户名
        var phoneRig = form2.phone.value;
        var codeRig = form2.code.value;
        if(codeRig==""){
            alert("请输入验证码");
            form2.codeRig.focus();
            return ;
        }
        form2.submit();
    }
    }


